####################################
# Test short
####################################
# 测试 IO 端口
ll /proc/ioports
sudo cat /proc/ioports

sudo modprobe -r parport_pc
sudo modprobe -r ppdev
sudo modprobe -r parport
sudo cat /proc/ioports
sudo dmesg -c

sudo ./short_load
sudo dmesg -c
ll /dev/short*
sudo cat /proc/ioports

echo -n  "any string" > /dev/short0
sudo dmesg -c

cat /dev/short0
sudo dmesg -c

dd if=/dev/short0 bs=1 count=1 | od -t x1
sudo dmesg -c
#../misc-progs/inp 0x378

echo -n 8 > /dev/shortint
sudo dmesg -c

cat /dev/shortint

# qemu run cmd line as follow:
#sudo gdb --args /home/liufeng/workspace/tools/bin/qemu-system-x86_64 -machine accel=kvm -m 4G \
#-hda /home/kvm/disk/vm0.img \
#-vnc 192.168.199.166:0 -monitor stdio \
#-netdev type=tap,id=eth0,ifname=tap30,script=no,downscript=no -device e1000,netdev=eth0,mac=12:03:04:05:06:08 \
#-parallel /dev/pts/2

# run hmp cmdline to trigger a interrupt
# about how to add hmp cmd parallel_intr_trigger
# reference: https://blog.csdn.net/leoufung/article/details/114736385?spm=1001.2014.3001.5501
parallel_intr_trigger

sudo dmesg -c

sudo ./short_unload
sudo dmesg -c

# 测试 IO 内存
ll /proc/ioports
sudo cat /proc/ioports
ll /proc/iomem
sudo cat /proc/iomem

sudo modprobe -r parport_pc
sudo modprobe -r ppdev
sudo modprobe -r parport
sudo modprobe -r virtio_net
sudo modprobe -r virtio_pci
sudo dmesg -c
sudo cat /proc/ioports
sudo cat /proc/iomem
sudo dmesg -c

#################################################
# 使用 vrtio_net的IO内存测试
sudo ./short_load use_mem=1 base=0xfe000000
sudo cat /proc/iomem
sudo dmesg -c
ll /dev/short*
echo -n 7 > /dev/short0
sudo dmesg -c

cat /dev/short0
sudo dmesg -c

sudo ./short_unload
sudo dmesg -c
sudo cat /proc/iomem

#################################################
# 测试其他的类型 s,p和int
sudo modprobe -r parport_pc
sudo modprobe -r ppdev
sudo modprobe -r parport
sudo cat /proc/ioports

sudo ./short_load
sudo dmesg -c
sudo cat /proc/ioports
ll /dev/short*

echo -n 7 > /dev/short0p
sudo dmesg -c
cat /dev/short0p
sudo dmesg -c


echo -n "any thing haha" > /dev/short0s
sudo dmesg -c
cat /dev/short0s
sudo dmesg -c

echo -n 8 > /dev/shortint
sudo dmesg -c

cat /dev/shortint
sudo dmesg -c

sudo ./short_unload
sudo dmesg -c

#################################################
# 测试其他的类型 w
sudo modprobe -r parport_pc
sudo modprobe -r ppdev
sudo modprobe -r parport
sudo cat /proc/ioports

sudo ./short_load short_irq=100 tasklet=1
sudo dmesg -c
sudo cat /proc/ioports
ll /dev/short*

echo -n 7 > /dev/short0
sudo dmesg -c
cat /dev/short0p
sudo dmesg -c


echo -n "any thing haha" > /dev/short0s
sudo dmesg -c
cat /dev/short0s
sudo dmesg -c

echo -n 8 > /dev/shortint
sudo dmesg -c

# qemu run cmd line as follow:
#sudo gdb --args /home/liufeng/workspace/tools/bin/qemu-system-x86_64 -machine accel=kvm -m 4G \
#-hda /home/kvm/disk/vm0.img \
#-vnc 192.168.199.166:0 -monitor stdio \
#-netdev type=tap,id=eth0,ifname=tap30,script=no,downscript=no -device e1000,netdev=eth0,mac=12:03:04:05:06:08 \
#-parallel /dev/pts/2

# run hmp cmdline to trigger a interrupt
parallel_intr_trigger

cat /dev/shortint
sudo dmesg -c

sudo ./short_unload
sudo dmesg -c

# 测试 Interrup
ll /proc/ioports
sudo cat /proc/ioports

sudo modprobe -r parport_pc
sudo modprobe -r ppdev
sudo modprobe -r parport
sudo cat /proc/ioports
sudo dmesg -c

sudo ./short_load
sudo dmesg -c
ll /dev/short*
sudo cat /proc/ioports

cat /proc/stat
cat /proc/interrupts

# qemu run cmd line as follow:
#sudo gdb --args /home/liufeng/workspace/tools/bin/qemu-system-x86_64 -machine accel=kvm -m 4G \
#-hda /home/kvm/disk/vm0.img \
#-vnc 192.168.199.166:0 -monitor stdio \
#-netdev type=tap,id=eth0,ifname=tap30,script=no,downscript=no -device e1000,netdev=eth0,mac=12:03:04:05:06:08 \
#-parallel /dev/pts/2

# run hmp cmdline to trigger a interrupt
# about how to add hmp cmd parallel_intr_trigger
# reference: https://blog.csdn.net/leoufung/article/details/114736385?spm=1001.2014.3001.5501
parallel_intr_trigger
cat /proc/interrupts

cat /dev/shortint
sudo dmesg -c

sudo ./short_unload
sudo dmesg -c

# probe = 1, system detect intr
sudo ./short_load probe=1
sudo dmesg -c
ll /dev/short*
sudo cat /proc/ioports

sudo ./short_unload
sudo dmesg -c


# probe = 2, system detect intr
sudo ./short_load probe=2
sudo dmesg -c
ll /dev/short*
sudo cat /proc/ioports

sudo ./short_unload
sudo dmesg -c


# tasklet = 1, system detect intr
sudo ./short_load tasklet=1
sudo dmesg -c
ll /dev/short*
sudo cat /proc/ioports

cat /proc/interrupts

#another tty
cat /dev/shortint

sudo dmesg -c
# qemu trigger 
parallel_intr_trigger

sudo dmesg -c
sudo ./short_unload
sudo dmesg -c


# wq=1, system detect intr
sudo ./short_load wq=1
sudo dmesg -c
ll /dev/short*
sudo cat /proc/ioports

cat /proc/interrupts

#another tty
cat /dev/shortint

sudo dmesg -c
# qemu trigger 
parallel_intr_trigger

sudo dmesg -c
sudo ./short_unload
sudo dmesg -c

# share=1, system detect intr
sudo ./short_load share=1
sudo dmesg -c
ll /dev/short*
sudo cat /proc/ioports

cat /proc/interrupts

#another tty
cat /dev/shortint

sudo dmesg -c
# qemu trigger 
parallel_intr_trigger

sudo dmesg -c
sudo ./short_unload
sudo dmesg -c









